package api

import (
	"stock/common/model"
	"stock/controller"
	"stock/controller/request"
	"stock/controller/response"
	"stock/global"

	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type Product struct {
	controller.Common
}

func (s Product) List(c *gin.Context) {

	page := s.P(c)
	var requestProduct request.Product
	c.ShouldBindBodyWith(&requestProduct, binding.JSON)

	productModel := new(model.ProductModel)
	product, _ := productModel.List(model.RequestProduct{
		MerchantType: 1,
		CheckState:   1,
		IsUp:         1,
		IsDelete:     0,
		Perfect:      []string{global.LANG_COUNTRY.Lang},
	}, page)

	var producMap response.ProductPcList
	producMap.Page = page.Page
	producMap.Limit = page.Limit
	producMap.List = product
	s.Success(producMap, global.LANG_COUNTRY.Lang, "成功", "Success", 200, c)
}
